<template>
  <j-form-container :disabled="formDisabled">
    <p style="margin-left: 20px;">经营者类型： {{operatortype}}</p>
    <a-page-header :ghost="false" title="基本信息" >
      <a-descriptions size="small" :column="4">
        <a-descriptions-item label="注册时间"> {{createTime}} </a-descriptions-item>
        <a-descriptions-item label="姓名"> {{name}} </a-descriptions-item>
        <a-descriptions-item label="手机号"> {{phone}} </a-descriptions-item>
        <a-descriptions-item label="身份证号"> {{identityid}} </a-descriptions-item>
        <a-descriptions-item label="性别"> {{sex_dictText}} </a-descriptions-item>
        <a-descriptions-item label="年龄"> {{age}} </a-descriptions-item>
      </a-descriptions>
    </a-page-header>

    <a-page-header :ghost="false" title="求职登记信息" >
      <a-descriptions size="small" :column="4">

        <a-descriptions-item label="意向工种"> {{yxgz}} </a-descriptions-item>
        <a-descriptions-item label="求职意向"> {{qzyx}} </a-descriptions-item>
        <a-descriptions-item label="期望薪资"> {{qwxz}} </a-descriptions-item>
        <a-descriptions-item label="意向地区"> {{yxdq}} </a-descriptions-item>
        <a-descriptions-item label="工作经验"> {{gzjy}} </a-descriptions-item>
        <a-descriptions-item label="学历"> {{xl}} </a-descriptions-item>
        <a-descriptions-item label="个人简介"> {{grjj}} </a-descriptions-item>
        <a-descriptions-item label="技能描述"> {{jnms}} </a-descriptions-item>
        <a-descriptions-item label="技能证书"><j-image-upload isMultiple v-model="jnzs"></j-image-upload></a-descriptions-item>>

      </a-descriptions>
    </a-page-header>

  </j-form-container>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JFormContainer from '@/components/jeecg/JFormContainer'
  import JDate from '@/components/jeecg/JDate'
  import JImageUpload from '@/components/jeecg/JImageUpload'

  export default {
    name: 'LhygPtUserForm',
    components: {
      JFormContainer,
      JDate,
      JImageUpload,
    },
    props: {
      //流程表单data
      formData: {
        type: Object,
        default: ()=>{},
        required: false
      },
      //表单模式：true流程表单 false普通表单
      formBpm: {
        type: Boolean,
        default: false,
        required: false
      },
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        form: this.$form.createForm(this),
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/business/lhygWxBusiness/add",
          edit: "/business/lhygWxBusiness/edit",
          queryById: "/business/lhygWxBusiness/queryById"
        },
        operatortype: '',
        createTime:'',
        name:'',
        phone:'',
        identityid:'',
        isjob:'',
        operatorarea:'',
        fundam: '',
        industryphy: '',
        ranges: '',
        gsbusinessname: '',
        gstraname: '',
        gsrange: '',
        gscreditcode: '',
        img: '',
        sex:'',
        sex_dictText:'',
        age:'',
        yxgz:'',
        qzyx: '',
        qwxz: '',
        yxdq: '',
        gzjy: '',
        xl: '',
        grjj: '',
        jnms: '',
        logo:'',
        gzsj:'',
        jnzs:'',
      }
    },
    computed: {
      formDisabled(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return false
          }
          return true
        }
        return this.disabled
      },
      showFlowSubmitButton(){
        if(this.formBpm===true){
          if(this.formData.disabled===false){
            return true
          }
        }
        return false
      }
    },
    created () {
      //如果是流程中表单，则需要加载流程表单data
      this.showFlowData();
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        const that = this;
        that.operatortype = record.operatortype_dictText;
        that.createTime = record.createTime;
        that.name = record.name;
        that.phone = record.phone;
        that.identityid = record.identityid;
        that.isjob = record.isjob_dictText;
        that.operatorarea = record.operatorarea;
        that.fundam = record.fundam;
        that.industryphy = record.industryphy_dictText;
        that.ranges = record.ranges;
        that.gsbusinessname = record.gsbusinessname;
        that.gstraname = record.gstraname;
        that.gsrange = record.gsrange;
        that.gscreditcode = record.gscreditcode;
        that.sex = record.sex;
        that.sex_dictText = record.sex_dictText;
        that.age = record.age;
        that.yxgz = record.yxgz;
        that.qzyx = record.qzyx;
        that.qwxz = record.qwxz;
        that.yxdq = record.yxdq;
        that.gzjy = record.gzjy;
        that.xl = record.xl;
        that.grjj = record.grjj;
        that.jnms = record.jnms;
        that.logo = record.logo;
        that.gzsj = record.gzsj;
        that.jnzs = record.jnzs;

        // this.form.resetFields();
        // this.model = Object.assign({}, record);
        this.visible = true;
        // this.$nextTick(() => {
        //   this.form.setFieldsValue(pick(this.model,'createTime','name','phone','identityid','operatortype','isjob','operatorarea','fundam','industryphy','ranges','gsbusinessname','gscreditcode','gsissuedate','gsrange','gstraname','ok','img'))
        // })
      },
      //渲染流程表单数据
      showFlowData(){
        if(this.formBpm === true){
          let params = {id:this.formData.dataId};
          getAction(this.url.queryById,params).then((res)=>{
            if(res.success){
              this.edit (res.result);
            }
          });
        }
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'createTime','updateTime','operatortype','isjob','operatorarea','fundam','industryphy','industryco','ranges','identityid','gsbusinessname','gscreditcode','gsdom','gsissuedate','gsrange','gstraname','ok','img','sex','sex_dictText','age','yxgz','qzyx','qwxz','yxdq','gzjy','xl','grjj','jnms','logo','gzsj','jnzs'))
      },
    }
  }
</script>

<style>
</style>